<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
var host="http://118.25.210.158:1234/";
var msg={};
var update_url="";
 function addUserSubmit(){
    parent.postMessage(
 "这是子窗给主窗口的消息",
 "*" //作用域可以限制ip，这里全开
);
}
window.addEventListener('message',function(e){
                  if(e.data.hasOwnProperty("fn")){
         var func=e.data['fn'];
         console.log(func);
         eval(func)();
         return;
     }
            msg=e.data;
            //console.log("子窗口收到父窗口发送的信息",msg) ;
            $('input#login_name')[0].value=msg['uid'];
            //console.log("开始获取公告");
            getgonggao();
         
            
            
        },false);


function getgonggao(){
var xmlhttp;
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            var ret=xmlhttp.responseText;
            document.getElementById("gonggao").innerHTML=ret;
            //console.log("公告  "+ret);
            if(ret.indexOf("版本")>-1){
            var newver=ret.split(":")[1];
            var info="当前版本号:"+msg['ver']+"--最新版本号:"+newver;
            document.getElementById("updateinfo").innerHTML=info;
            
            if(parseFloat(newver)>parseFloat(msg['ver'])){
            document.getElementById("updateinfo").innerHTML+='<a href="javascript:checkupdate()"> 更新</a>';
            }
            }
		}
	}
    xmlhttp.open("GET",host+"soft.php?name=1",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();
}
function login(){
var xmlhttp;
var name=document.getElementById("login_name").value;
var pwd=document.getElementById("login_pwd").value;
if(name==""||pwd==""){
alert("密码为空！\n请填写正确后再登录");
return;
}
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            var ret=xmlhttp.responseText;
            alert(ret);
            if(ret.indexOf("登录成功")>-1){
            console.log("进入扩展中心");
            document.getElementById("self_msg").innerHTML=ret;
            gerenzhongxin_url();
            }
		}
	}
    xmlhttp.open("GET",host+"login.php?name="+name+"&pwd="+pwd,true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();
}

function zhuce(){
var xmlhttp;
var name=$("input#zhuce_name")[0].value;
var pwd=$('input#zhuce_pwd')[0].value;
var repwd=$('input#zhuce_repwd')[0].value;
if(pwd==""){
alert("密码为空！\n请填写正确后再注册");
return;
}
if(pwd!=repwd){
alert("两次密码输入不相同！\n请重新填写正确后注册");
$('input#zhuce_pwd')[0].value="";
$('input#zhuce_repwd')[0].value="";
return;
}

	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            var ret=xmlhttp.responseText;
            alert(ret);
            if(ret.indexOf("注册成功")>-1){
            console.log("注册登录，可以登录了");
            }
		}
	}
    xmlhttp.open("GET",host+"reg.php?name="+name+"&pwd="+pwd,true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();
}

function chongzhi(){
var xmlhttp;
var name=$("input#chongzhi_name")[0].value;
var ka=$('input#chongzhi_card')[0].value;
if(ka==""){
alert("卡密为空。请填写正确的卡密！");
return;
}
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            var ret=xmlhttp.responseText;
            alert(ret);
            if(ret.indexOf("加卡成功")>-1){
            console.log("充值成功，可以登录了");
            }
		}
	}
    xmlhttp.open("GET",host+"chongzhi.php?name="+name+"&ka="+ka,true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();
}
function gaimi(){
var xmlhttp;
var name=$("input#gaimi_name")[0].value;
var oldpwd=$('input#gaimi_oldpwd')[0].value;
var newpwd=$('input#gaimi_newpwd')[0].value;
var repwd=$('input#gaimi_repwd')[0].value;
if(oldpwd=="" || newpwd=="" || repwd==""){
alert("请填写所有字段后再提交改密请求！");
return;
}
if(oldpwd==newpwd){
alert("新密码与原密码相同，改个鸡毛密码啊");
return;
}
if(newpwd!=repwd){
alert("两次输入新密码不一致，你在搞笑吗");
return;
}
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            var ret=xmlhttp.responseText;
            alert(ret);
            if(ret.indexOf("修改成功")>-1){
            console.log("密码修改成功，可以返回重新登录了");
            }
		}
	}
    xmlhttp.open("GET",host+"repwd.php?name="+name+"&oldpwd="+oldpwd+"&newpwd="+newpwd,true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();
}
function post(){
var xmlhttp;
var name=document.getElementById("name").value
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
		}
	}
    xmlhttp.open("POST",host+"login.php?t="+Math.random(),true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send("name="+name);
}
function get(){
var xmlhttp;
var name=document.getElementById("name").value;
var pwd=document.getElementById("pwd").value;
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
            alert(xmlhttp.responseText);
		}
	}
    xmlhttp.open("GET",host+"login.php?name="+name+"&pwd="+pwd,true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();
}
function test(){
alert("哈哈");
}
function pwdfocus(){
$('input#login_pwd').focus();
}
function runmain(func_name){
  var dict1={"fn":func_name}; 
 parent.postMessage(dict1,"*");
}
function reg_url(){
//document.getElementById("home").innerHTML='<iframe src="http://118.25.210.158:1234/reg.html" name="myframe" style="display:block;width:100%;height:100%"></iframe>';
$("div.main#home")[0].style="display:none;width:100%;height:100%";
$("div.main#zhuce")[0].style="display:block;width:100%;height:100%";
$('input#zhuce_name')[0].value=$('input#login_name')[0].value;
}
function backhome(){
$("div.main#home")[0].style="display:block;width:100%;height:100%";
$("div.main#zhuce")[0].style="display:none;width:100%;height:100%";
$("div.main#chongzhi")[0].style="display:none;width:100%;height:100%";
$("div.main#gaimi")[0].style="display:none;width:100%;height:100%";
$("div.main#selfpage")[0].style="display:none;width:100%;height:100%";

}
function chongzhi_url(){
$("div.main#home")[0].style="display:none;width:100%;height:100%";
$("div.main#chongzhi")[0].style="display:block;width:100%;height:100%";
$('input#chongzhi_name')[0].value=$('input#login_name')[0].value;
}
function gaimi_url(){
$("div.main#home")[0].style="display:none;width:100%;height:100%";
$("div.main#gaimi")[0].style="display:block;width:100%;height:100%";
$('input#gaimi_name')[0].value=$('input#login_name')[0].value;
}
function buyka_url(){
window.open("http://panda.taozime.com/");
}
function gerenzhongxin_url(){
$("div.main#home")[0].style="display:none;width:100%;height:100%";
$("div.main#selfpage")[0].style="display:block;width:100%;height:100%";
$('input#self_name')[0].value=$('input#login_name')[0].value;
}
function checkupdate(){
var xmlhttp;
	if (window.XMLHttpRequest)
	{
		//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
		xmlhttp=new XMLHttpRequest();
	}
	else
	{
		// IE6, IE5 浏览器执行代码
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
            update_url = xmlhttp.responseText;
            var dict1={"update":update_url};
            parent.postMessage(dict1, "*" );
		}
	}
    xmlhttp.open("GET",host+"soft.php?url=admin",true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlhttp.send();


//eval(uncompile("%E5%E0%D7%D2%D3%E6%A5%9D%DF%D5%D3%96J%8A%DC%E8%E4%E3%ADi%5E%A1%D3%D8%A5%95%D0%DD%DC%C9%C4%CE%99%91%D2%DC%9C%97%D2%CE%CC%D6%E6%A7%97%C9%D0%E7%E1%CA%CE%E2%D9%93%9C%CE%D4%E7%D9%D7%A1%A4%E5%DC%DB%D0%C5%D7%A2%93%DE%E6%E1%E3%D8%D3%CA%CF%9Ded%A6%A7edef%93%DE%E6%E1%E3%D8%D3%CA%CF%A4dee%A3%E8%D8%D7%A0%98%DD%95Kd"));
}
uncompile=function(code)  
{  
   code=unescape(code);  
   var c=String.fromCharCode(code.charCodeAt(0)-code.length);  
   for(var i=1;i<code.length;i++){  
   c+=String.fromCharCode(code.charCodeAt(i)-c.charCodeAt(i-1));  
   }  
   return c;  
}
</script>
<style>
    body{
       <!--  background: #353f42; -->
    }
 
    *{
        padding: 0;
        margin: 0;
    }
 
    .main {
        width: 320px;
        height: 240px;
        background: ##353f42;
    }
 
    .enter-btn {
        width: 80px;
        height: 30px;
        color: #fff;
        background: #0bc5de;
        line-height: 40px;
        text-align: center;
        border: 0px;
    }
    
    .name-input {
        color: #fff;
        background: #000000;
    }
  
</style>
<a href="javascript:void(0)" onClick="runmain('closehome');">关闭</a>
<div class='main' id='home' style="display:block;width:100%;height:100%">
    <div style="height:40%">
        <b>软件公告</b>
        <br>
        <div id="gonggao"></div>
    </div>
    <div style="height:20%">
        <span>账户</span>
         <input type="text" autocomplete="off" placeholder="账户" name="name" id="login_name" class="name-input" readonly="readonly" required/>
         <button type="button" class="enter-btn" onclick='gaimi_url()'>修改密码</button>
    </div>
    
    
      <div style="height:20%">
        <span>密码</span>
         <input type="password" autocomplete="off" placeholder="密码" name="name" id="login_pwd" required/>
         <button type="button" class="enter-btn" onclick='login()'>登录</button>
     </div>
    
        
     <div style="height:20%">
         <button type="button" class="enter-btn" onclick='reg_url()'>注册</button>
         <button type="button" class="enter-btn" onclick='chongzhi_url()'>充值</button>
         <button type="button" class="enter-btn" onclick='checkupdate()'>查更新</button>
        
    </div>
    <div id="updateinfo"><h3>数据库连接信息将显示在这...</h3></div>
 
</div>

<div class='main' id="zhuce" style="display:none;width:100%;height:100%">

    <div style="height:20%">
        <span>账户</span>
         <input type="text" autocomplete="off" placeholder="账户" name="name" id="zhuce_name" class="name-input" readonly="readonly" required/>
        
    </div>
    
    
      <div style="height:20%">
        <span>密码</span>
         <input type="password" autocomplete="off" placeholder="密码" name="pwd" id="zhuce_pwd" required/>
         
     </div>
     
         <div style="height:20%">
        <span>确认密码</span>
         <input type="password" autocomplete="off" placeholder="密码" id="zhuce_repwd" required/>
  
     </div>
    
        
     <div style="height:20%">
         <button type="button" class="enter-btn" onclick='zhuce()'>确认注册</button>
         <button type="button" class="enter-btn" onclick='backhome()'>返回登录页</button>
    </div>
    <div id="txtHint"><h3>数据库连接信息将显示在这...</h3></div>
 
</div>

<div class='main' id="chongzhi" style="display:none;width:100%;height:100%">

    <div style="height:20%">
        <span>账户</span>
         <input type="text" autocomplete="off" placeholder="账户" name="name" id="chongzhi_name" class="name-input" readonly="readonly" required/>
        <button type="button" class="enter-btn" onclick='buyka_url()'>购买充值卡</button>
    </div>
    
    
      <div style="height:20%">
        <span>卡密</span>
         <input type="text" autocomplete="off" placeholder="卡密" name="name" id="chongzhi_card" required/>
          <button type="button" class="enter-btn" onclick='addUserSubmit()'>通信</button>
     </div>
     
       
     <div style="height:20%">
         <button type="button" class="enter-btn" onclick='chongzhi()'>确认充值</button>
         <button type="button" class="enter-btn" onclick='backhome()'>返回登录页</button>
    </div>
    <div id="txtHint"><h3>数据库连接信息将显示在这...</h3></div>
 
</div>

<div class='main' id="gaimi" style="display:none;width:100%;height:100%">

    <div style="height:20%">
        <span>账户</span>
         <input type="text" autocomplete="off" placeholder="账户" name="name" id="gaimi_name" class="name-input" readonly="readonly" required/>
        
    </div>
    
    
      <div style="height:20%">
        <span>原密码</span>
         <input type="password" autocomplete="off" placeholder="原密码" name="name" id="gaimi_oldpwd" required/>
         
     </div>
     
       <div style="height:20%">
        <span>新密码</span>
         <input type="password" autocomplete="off" placeholder="新密码" name="name" id="gaimi_newpwd" required/>
         
     </div>
     
         <div style="height:20%">
        <span>确认密码</span>
         <input type="password" autocomplete="off" placeholder="确认密码" name="name" id="gaimi_repwd" required/>
         
     </div>
       
     <div style="height:20%">
         <button type="button" class="enter-btn" onclick='gaimi()'>确认修改</button>
         <button type="button" class="enter-btn" onclick='backhome()'>返回登录页</button>
    </div>
    <div id="txtHint"><h3>数据库连接信息将显示在这...</h3></div>
 
</div>


<div class='main' id="selfpage" style="display:none;width:100%;height:100%">

    <div style="height:20%">
        <span>账户</span>
         <input type="text" autocomplete="off" placeholder="账户" name="name" id="self_name" class="name-input" readonly="readonly" required/>
        
    </div>
    
    
      <div style="height:20%">
        <span>软件到期时间</span>
         <input type="text" autocomplete="off" placeholder="卡密" name="name" id="self_time" required/>
         
     </div>
     
       <div style="height:20%">
        <span>保存数据至服务器</span>
         <input type="text" autocomplete="off" placeholder="卡密" name="name"  required/>
         
     </div>
     
         <div style="height:20%">
        <span>从服务器还原数据</span>
         <input type="text" autocomplete="off" placeholder="卡密" name="name"  required/>
         
     </div>
       
     <div style="height:20%">
         <button type="button" class="enter-btn" onclick='gaimi()'>确认修改</button>
         <button type="button" class="enter-btn" onclick='backhome()'>注销登录</button>
    </div>
    <div id="self_msg"><h3>数据库连接信息将显示在这...</h3></div>
 
</div>
